﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO.IsolatedStorage;
using System.Windows.Resources;
using System.IO;
using System.Text;

namespace StudyEnglish
{
    public partial class VolDetail : PhoneApplicationPage
    {
        int id;
        public VolDetail()
        {
            InitializeComponent();
        }

      

        private string FormatHTML(string content)
        {
            string result = string.Empty;
                        StringBuilder htmlText = new StringBuilder();
                        htmlText.Append("<html>");
                        htmlText.Append("<body style='background-color:Black;color:white' >");
                        htmlText.Append(content);
                        htmlText.Append("</body>");
                        htmlText.Append("</html>");
                        result = htmlText.ToString();
            return result;
        }

        private void loadData()
        {

           string content =  FormatHTML(App.VolVM.VolByID.Sentence);
           webBrowser1.NavigateToString(content);
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string selectedID;
            if (NavigationContext.QueryString.TryGetValue("id", out selectedID))
            {
                id = int.Parse(selectedID);
                App.VolVM.GetVolByID(id);
                this.DataContext = App.VolVM.VolByID;
                loadData();
               
            }
        }

        private void btn_speaker_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
        {
            webBrowser1.OpacityMask = null;
            webBrowser1.Opacity = 1;
        }
    }
}